package com.oracle.oa.test;


import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.oracle.oa.biz.UserInfoBiz;
import com.oracle.oa.biz.impl.OperatelogBizImpl;
import com.oracle.oa.biz.impl.UserInfoBizImpl;
import com.oracle.oa.dao.BaseDao;
import com.oracle.oa.dao.ManualSignDao;
import com.oracle.oa.entity.Manualsign;
import com.oracle.oa.entity.Roleinfo;
import com.oracle.oa.entity.Userinfo;
import com.oracle.oa.util.PageBean;


public class test {
//	OperatelogDao oDao=new OperatelogDaoImpl();
//	LoginLogBiz lbiz=new LoginLogBizImpl();
	//@Test
//	public void test1(){
//		Operatelog operatelog=new Operatelog();
//		operatelog=(Operatelog) oDao.getById(Operatelog.class, 5l);
//		oDao.save(operatelog);
//		System.out.println(operatelog.getOperateid());
//		List<Loginlog> list=new ArrayList<Loginlog>();
//		list=lbiz.getAll(Loginlog.class);
//		for (Loginlog loginlog : list) {
//			loginlog.getLogintime();
//		}
//	}

	//@Test
	public void testSplit() {
		ApplicationContext app=new ClassPathXmlApplicationContext("applicationContext.xml");
		BaseDao bdao=(BaseDao) app.getBean("dao");
		PageBean p=new PageBean();
		p.setCurrentPage(1);
		DetachedCriteria dc=DetachedCriteria.forClass(Roleinfo.class);
		
		bdao.splitPage1(p, dc, Roleinfo.class);
	}
	//@Test
	public void testGetAll(){
		ApplicationContext app=new ClassPathXmlApplicationContext("applicationContext.xml");
		BaseDao bdao=(BaseDao) app.getBean("dao");
		List<Userinfo> list=bdao.getAll(Userinfo.class);
		for (Userinfo userinfo : list) {
			System.out.println(userinfo.getUsername());
		}
	}
//	@Test
	public void test12(){
		OperatelogBizImpl.add("wode", "wejfi");
	}
	//@Test
	public void testgetu(){
		UserInfoBiz ubiz = new UserInfoBizImpl();
		List<Userinfo> ulist = ubiz.getBydepartAndUsername("人事部", "a");
		for(Userinfo u:ulist){
			System.out.println(u.getUsername()+"\t"+u.getUserid());
		}
	}
	
	//@Test
	public void test2(){
		
//		MyNoteDao mndao=new MyNoteDaoImpl();
		
		 //与xml文件关联
		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
		//获取对象
//		BaseDao bdao=(BaseDao) ac.getBean("dao");
		
		
		/*DepartInfoBiz dao=(DepartInfoBiz) ac.getBean("dbiz");
		
		Departinfo depart=dao.findByDepartInfoName("人事部");
		
		
		System.out.println("123213-----"+depart.getDepartname());*/
		
		
		
		
//		MyNoteDao mndao=(MyNoteDao)ac.getBean("mndao");
//		MyNoteBiz mnbiz=(MyNoteBiz)ac.getBean("mnbiz");
		
		//List<Mynote> list=bdao.getAll(Mynote.class);
//		Mynote m=(Mynote) bdao.getById(Mynote.class, 1l);
//		Schedule s=(Schedule) bdao.getById(Schedule.class, 1l);
//		List<MyNote> mlist = (List<MyNote>)mnbiz.getAll(MyNote.class);
//		System.out.println(s.getUserinfo().getUsername());
	    
//		List<Calendar> clist=bdao.getByProperty(Calendar.class,"start1", "2016-5-12");
		
//		List<Calendar> clist=bdao.getByProperty(Calendar.class,"title", "日程title");
		
		
//		CalendarDao cdl=(CalendarDao) ac.getBean("caldao");
//		
//		String s="";
//		List<Calendar> clist=cdl.findBytiem("start1",s);
//				
//		System.out.println(clist.size());
		
//		ScheduleBiz sbiz=(ScheduleBiz) ac.getBean("sbiz");
//		
//		List<Schedule> slizt=sbiz.findByDCC(1l, 0l, 1001l);
//		
//		System.out.println(slizt.size());
//		
		
	}
	
//	@Test
	public void testgetPuByTime(){
		
		 //与xml文件关联
		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
		
		ManualSignDao md=(ManualSignDao) ac.getBean("msdao");
		
		UserInfoBiz ub=(UserInfoBiz) ac.getBean("ubiz");
		
		Userinfo user=(Userinfo) ub.getById(Userinfo.class, 1002l);
		
		List<Manualsign> ms= md.getPgByTime(user, "2016-05-01", "2016-06-09");
		for(Manualsign m:ms){
			System.out.println(m.getSigntime());
		}
		System.out.println(user.getUsername());
	}

}
